<template>
<div>
  {{userid}}
  <h1>新闻展示</h1>
  <ul>
    <li>新闻</li>
  </ul>
  <ul v-for="i in news">
    <li>
      <button @click="new_xq(i.id)">{{i.bt}}</button>
    </li>

  </ul>
  <button @click="show_new(i)" v-for="i in num">{{i}}</button>

</div>
</template>

<script>
export default {
  name: "News",
  data(){
    return{
      news:[],
      num: "",
      userid:localStorage.getItem('userid')
    }
  },
  methods:{
    show_new(i){
      this.$axios.get("users/News_API/?cpage="+i)
      .then(i=>{
        this.num = i.data.num
        this.news = i.data.list
      })
    },
    new_xq(id){
      if (this.userid){
        this.$router.push({path:'/news_xq',query:{id:id}})

      }
    }
  },
  mounted() {
    this.show_new(1)
  }
}
</script>

<style scoped>

</style>
